/**
 * 创建Loca对象
 * @param map
 * @returns {postcss.Container}
 * @private
 */
export function _createLoca(map) {
    var loca = window.loca = new Loca.Container({
        map,
    });

    loca.ambLight = {
        intensity: 2.2,
        color: '#babedc',
    };
    loca.dirLight = {
        intensity: 0.46,
        color: '#d4d4d4',
        target: [0, 0, 0],
        position: [0, -1, 1],
    };
    loca.pointLight = {
        color: 'rgb(15,19,40)',
        position: [106.56288, 29.556742, 200],
        intensity: 25,
        // 距离表示从光源到光照强度为 0 的位置，0 就是光不会消失。
        distance: 3900,
    };

    return loca;
}

export function _createLocaPolygon(loca) {
    //3d建筑
    var geo = new Loca.GeoJSONSource({
        data: {
            "type": "FeatureCollection",
            "name": "sh_building_center",
            "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:OGC:1.3:CRS84"}},
            "features": [
                {
                    "type": "Feature",
                    "properties": {"mainKey": 500101, "h": 150},
                    "geometry": {
                        "type": "Polygon",
                        "coordinates": [[[106.562238,29.557506], [106.564455,29.555875], [106.562308,29.554295], [106.560445,29.556535]]]
                    }
                }]
        },
    });
    var pl = window.pl = new Loca.PolygonLayer({
        zIndex: 120,
        shininess: 10,
        hasSide: true,
        cullface: 'back',
        depth: true,
    });

    pl.setSource(geo);
    pl.setStyle({
        topColor: '#111',
        height: function (index, feature) {
            return feature.properties.h;
        },
        textureSize: [1000, 820],
        texture: 'https://a.amap.com/Loca/static/loca-v2/demos/images/windows.jpg',
    });
    pl.setLoca(loca)
}
